package com.lineage.data.item_etcitem.add;

import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1MonsterInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.world.WorldMob;
import java.util.Iterator;

public class Boss_Radar extends ItemExecutor {
  public static ItemExecutor get() {
    return new Boss_Radar();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    pc.sendPackets((ServerBasePacket)new S_SystemMessage("使用野狼的嗅觉，找寻目标......"));
    L1MonsterInstance find_npc = null;
    Iterator<L1MonsterInstance> itr = WorldMob.get().getAllMonster().iterator();
    while (itr.hasNext()) {
      L1MonsterInstance boss = itr.next();
      if (boss.getNpcTemplate().is_boss() && boss.getMapId() == pc.getMapId() && !boss.isDead()) {
        find_npc = boss;
        if (find_npc == null) {
          pc.sendPackets((ServerBasePacket)new S_SystemMessage("这里已经没有BOSS的气味，好像晚了一步..."));
          break;
        } 
        pc.sendPackets((ServerBasePacket)new S_SystemMessage(
              "从 " + find_npc.getX() + "," + find_npc.getY() + " 处，传来 " + find_npc.getName() + " 的气味~~~"));
      } 
    } 
  }
}
